﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace CopyDirRec
{
    class CopyDir
    {
        static void CopySubdirectories(DirectoryInfo source, DirectoryInfo destination)
        {
            foreach (FileInfo file in source.GetFiles())
            {
                File.Copy(file.FullName, destination.FullName + "\\" + file.Name);
            }
            foreach (DirectoryInfo dir in source.GetDirectories())
            {
                destination.CreateSubdirectory(dir.Name);
                DirectoryInfo subDir = new DirectoryInfo(destination.FullName + "\\" + dir.Name);
                CopySubdirectories(dir, subDir);
            }
        }

        static void Main()
        {
            string sourceDirPath = @"C:\Users\Academy\Documents\Visual Studio 2010\" +
            @"Projects\netessentials\TestGeneratorAIMI\StreamExercise\SearchTextFiles\bin\Debug\dir";
            string destinationDirPath = @"C:\Users\Academy\Documents\Visual Studio 2010\" +
                @"Projects\netessentials\TestGeneratorAIMI\CopyDirRec\bin\Debug\dir";

            DirectoryInfo source = new DirectoryInfo(sourceDirPath);
            DirectoryInfo destination = new DirectoryInfo(destinationDirPath);
            destination.Create();

            CopySubdirectories(source, destination);
        }
    }
}
